let search = document.querySelector("#search")
let num = 0
$.ajax({
    url: "http://chst.vip:1234/api/getindexmenu",
    responseType: "json",
})
    .then((res) => {
        console.log(res)
        let divs = "";
        res.result.forEach(item => {
            num++
            divs += `<div>
            <div>
                <a href="${item.titlehref}"><img src="../assets/images/${num}.png" alt=""></a>
                <span>${item.name}</span>
            </div>
        </div>`
        });
        search.innerHTML = divs
        return res
    })
    .then((res) => {
        let flag = true
        $("#search>div:eq(7)").click(function () {
            if (flag) {
                $("#search").stop().animate({ height: 200, }, 300)
                flag = false
            } else {
                $("#search").stop().animate({ height: 309, }, 300)
                flag = true
            }
        })
        return res
    })
    .then((res) => {
        $("#search>div").click(function () {
            console.log(this);
        })
    })
// 搜索渲染

let recommen = document.querySelector("#recommen")
$.ajax({
    url: "http://chst.vip:1234/api/getmoneyctrl",
    responseType: "json",
})
    .then((res) => {
        let divs = "";;
        res.result.forEach(item => {
            divs += `<a href="indexXiang.html?productid${item.productId}">
           <span>${item.productImgSm}</span>
            <div>
                <div>
                    <h4>${item.productName}</h4>
                    <span>${item.productPinkage}</span>
                </div>
                <div>
                    <span>
                        <span>${item.productFrom}</span>
                        <span>${item.productTime}</span>
                    </span>
                    <p>${item.productComCount}</p>
                </div>
            </div>
        </a>`
        });
        recommen.innerHTML = divs
    })

$("#backtop").click(function () {
    console.log(123);
    $("html").animate({ scrollTop: 0 }, 1000)
})